package com.huike.web.controller.report;


import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.huike.clues.domain.TbActivity;
import com.huike.clues.domain.vo.ClueReportVo;
import com.huike.common.core.controller.BaseController;
import com.huike.common.core.domain.AjaxResult;
import com.huike.report.domain.vo.IndexVo;
import com.huike.report.service.IReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.core.page.TableDataInfo;
import com.huike.report.domain.dto.ContractStatisticsDTO;
import com.huike.report.domain.dto.StatisticsPageDTO;
import com.huike.report.domain.vo.*;
import com.huike.report.service.IReportService;
import org.apache.ibatis.annotations.Param;
import org.simpleframework.xml.Path;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import com.huike.common.core.domain.AjaxResult;
import com.huike.report.domain.vo.VulnerabilityMapVo;
import com.huike.report.service.IReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.GetMapping;
import java.time.LocalDate;


import java.time.LocalDate;
import java.util.List;

@RestController
@RequestMapping("/report")
public class ReportController extends BaseController {
    @Autowired
    private IReportService reportService;


    @GetMapping("/getVulnerabilityMap/{beginCreateTime}/{endCreateTime}")
    public AjaxResult getVulnerabilityMap(@PathVariable String beginCreateTime, @PathVariable String endCreateTime) {
        VulnerabilityMapVo vulnerabilityMapVo = reportService.getVulnerabilityMap(beginCreateTime, endCreateTime);

        return AjaxResult.success(vulnerabilityMapVo);

    }

    @GetMapping("/chanelStatistics/{beginCreateTime}/{endCreateTime}")
    public  List<ChannelStatisticsVO> chanelStatistics(@PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd")LocalDate beginCreateTime,
                                       @PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd")LocalDate endCreateTime){
        List<ChannelStatisticsVO> channelStatisticsVO = reportService.chanelStatistics(beginCreateTime, endCreateTime);
        if (channelStatisticsVO.size() == 0){
            return null;
        }
        return channelStatisticsVO;
    }

    @GetMapping("/activityStatistics/{beginCreateTime}/{endCreateTime}")
    public List<ActivityStatistics> activityStatistics(@PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd")LocalDate beginCreateTime,
                                                 @PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd")LocalDate endCreateTime){
        List<ActivityStatistics> activityStatistics = reportService.activityStatistics(beginCreateTime, endCreateTime);
        return activityStatistics;
    }

    @GetMapping("/cluesStatistics/{beginCreateTime}/{endCreateTime}")
    public LineChartVO cluesStatistics(@PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate beginCreateTime
                                        ,@PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd")LocalDate endCreateTime){
        LineChartVO lineChartVO = reportService.cluesStatistics(beginCreateTime, endCreateTime);
        return lineChartVO;
    }

    @GetMapping("/activityStatisticsList")
    public TableDataInfo  activityStatisticsList(Integer pageNum,Integer pageSize,
                                                 @DateTimeFormat(pattern = "yyyy-MM-dd")LocalDate beginCreateTime,
                                                 @DateTimeFormat(pattern = "yyyy-MM-dd")LocalDate endCreateTime,
                                                 String name,String code,Integer total){

        TableDataInfo tableDataInfo = reportService.activityStatisticsList(pageNum, pageSize, beginCreateTime, endCreateTime, name, code, total);

        return tableDataInfo;
    }

    @GetMapping("/cluesStatisticsList")
    public TableDataInfo cluesStatisticsList(Integer pageNum,Integer pageSize,
                                          @DateTimeFormat(pattern = "yyyy-MM-dd")LocalDate beginCreateTime,
                                          @DateTimeFormat(pattern = "yyyy-MM-dd")LocalDate endCreateTime,
                                          Long id,String owner){
        TableDataInfo tableDataInfo = reportService.cluesStatisticsList(pageNum, pageSize, beginCreateTime, endCreateTime, id, owner);
        System.out.println(tableDataInfo+"tableDataInfo");
        return tableDataInfo;
    }

    @GetMapping("/contractStatistics/{beginCreateTime}/{endCreateTime}")
    public LineChartVO contractStatistics(
            @PathVariable
            @DateTimeFormat(pattern = "yyyy-MM-dd")
            LocalDate beginCreateTime,
            @PathVariable
            @DateTimeFormat(pattern = "yyyy-MM-dd")
            LocalDate endCreateTime
    ){

        return reportService.contractStatistics(beginCreateTime,endCreateTime);
    }

    @GetMapping("/contractStatisticsList")
    public TableDataInfo contractStatisticsList(ContractStatisticsDTO contractDTO) {
        return reportService.contractStatisticsList(contractDTO);
    }

    @GetMapping("/subjectStatistics/{beginCreateTime}/{endCreateTime}")
    public List<SubjectStatisticsVO> subjectStatistics(
            @PathVariable
            @DateTimeFormat(pattern = "yyyy-MM-dd")
            LocalDate beginCreateTime,
            @PathVariable
            @DateTimeFormat(pattern = "yyyy-MM-dd")
            LocalDate endCreateTime
    ) {
        return reportService.subjectStatistics(beginCreateTime, endCreateTime);
    }

    @GetMapping("/salesStatistics/{beginCreateTime}/{endCreateTime}")
    public LineChartVO salesStatistics(
            @PathVariable
            @DateTimeFormat(pattern = "yyyy-MM-dd")
            LocalDate beginCreateTime,
            @PathVariable
            @DateTimeFormat(pattern = "yyyy-MM-dd")
            LocalDate endCreateTime
    ) {
        return reportService.salesStatistics(beginCreateTime, endCreateTime);
    }

    @GetMapping("/deptStatisticsList/{beginCreateTime}/{endCreateTime}")
    public TableDataInfo deptStatisticsList(
            @PathVariable
            @DateTimeFormat(pattern = "yyyy-MM-dd")
            LocalDate beginCreateTime,
            @PathVariable
            @DateTimeFormat(pattern = "yyyy-MM-dd")
            LocalDate endCreateTime,
            StatisticsPageDTO dto
    ) {

        TableDataInfo tableDataInfo = reportService.deptStatisticsList(dto);
        tableDataInfo.setCode(200);
        return tableDataInfo;
    }

    @GetMapping("/ownerShipStatisticsList/{beginCreateTime}/{endCreateTime}")
    public TableDataInfo ownerShipStatisticsList(
            @PathVariable
            @DateTimeFormat(pattern = "yyyy-MM-dd")
            LocalDate beginCreateTime,
            @PathVariable
            @DateTimeFormat(pattern = "yyyy-MM-dd")
            LocalDate endCreateTime,
            StatisticsPageDTO dto) {
        return reportService.ownerShipStatisticsList(dto);
    }

    @GetMapping("/channelStatisticsList/{beginCreateTime}/{endCreateTime}")
    public TableDataInfo channelStatisticsList(
            @PathVariable
            @DateTimeFormat(pattern = "yyyy-MM-dd")
            LocalDate beginCreateTime,
            @PathVariable
            @DateTimeFormat(pattern = "yyyy-MM-dd")
            LocalDate endCreateTime,
            StatisticsPageDTO dto) {
        return reportService.channelStatisticsList(dto);
    }





}
